<!DOCTYPE html>
<html lang="zh-CN">

<head>
	<meta charset="UTF-8">
	<title>百灵快传</title>
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="renderer" content="webkit|ie-comp|ie-stand" />
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="../assets/css/main.css?03">
</head>

<body>
<div class="layui-fluid x-body">
	<blockquote class="layui-elem-quote" style="text-align: center">
		<div>手机电脑文件传输||局域网文件服务器</div>
		${range .ips}
		<div class="home-index-tips">
			<div class="home-index-tips-left">
				<a onclick="openQrcode('${.}')" title="手机扫码传输文件">
				<b><i class="iconfont">&#xe6ec;</i> ${.}</b>
				</a>
			</div>
			<div class="home-index-tips-right">
			<a href="http://${.}" target="_top" title="刷新">
				<i class="layui-icon layui-icon-refresh-3"></i>
			</a>
			<a href="http://${.}/files/" target="_top" title="列表形式">
				<i class="iconfont">&#xe6b5;</i>
			</a>
			</div>
		</div>
		${end}

		<div class="home-index-tips">
			<div class="home-index-tips-left">
				<a href="api/openurl?url=${.path_root}" target="iframe-hide" title="打开文件根目录" onclick="messageOk('在主电脑打开文件根目录成功');">
					<b><i class="layui-icon layui-icon-layouts"></i> ${.path_root}</b>
				</a>
			</div>
			<div class="home-index-tips-right">
				<a href="api/openurl?url=${.path_root}" target="iframe-hide" title="打开" onclick="messageOk('在主电脑打开文件根目录成功');">
					<i class="layui-icon layui-icon-more"></i>
					<i class="layui-icon layui-icon-next"></i>
				</a>
			</div>
		</div>

		<div id="uesr_list"></div>

	</blockquote>


	<div class="layui-row layui-col-space15">
		${range .flists}
	<div class="layui-col-xs6 layui-col-sm4 layui-col-md3 layui-col-lg2">
		<div class="layui-card bg-gray">
			<div class="layui-card-header inline-text">
				<b title="${.name}">${.indexs}. ${.name}</b>

			</div>
			<div class="layui-card-body layuiadmin-card-list">
				<p class="layuiadmin-big-font" style="text-align: center">

					<a onclick="openView('${.name}','${.path}','${.type}')">
						${if eq .type "img"}
						<img src="files/${.path}" height="50"  alt="${.name}"/>
						${else}
						<div class="filebox">${.ext}</div>
						${end}
					</a>

				</p>
				<div class="inline-small" style="margin-top:10px;">
					<div>${.sizes}</div>
					<div class="right-span">
						<i onclick="deleteFile('${.path}')" class="layui-badge layui-bg-gray layuiadmin-badge layui-icon layui-icon-delete"></i>
					</div>
					<div class="right-span2">
						<a href="/api/openurl?url=${$.path_root}/${.path}" target="iframe-hide" title="投屏在电脑" onclick="messageOk('在主电脑投屏成功');">
						<i class="layui-badge layui-bg-gray layuiadmin-badge layui-icon layui-icon-chart-screen"></i>
						</a>
					</div>
				</div>
			</div>
		</div>
	</div>
		${end}
	</div>

</div>
<iframe name="iframe-hide" class="layui-hide"></iframe>
<script type="text/javascript" src="../js/libs/jquery.min.js "></script>
<script type="text/javascript" src="../js/libs/layui/layui.js"></script>
<script type="text/javascript" src="../js/main.js?01"></script>
<script type="text/javascript" src="../js/utils.js?01"></script>
<script type="text/javascript" src="../js/download.js?01"></script>
<script type="text/javascript" src="js/sync.js?01"></script>
<script>

	function syncDo(data) {
		var msg=data.msg;
		console.log(msg);
		if(msg==='reload'){
			window.location.reload();
		}
		/*if(data.clientId=="0"){
			$("#uesr_list").html(msg);
		}*/
	}

	function openQrcode(ip){
		x_admin_open('手机扫码','./page/qrcode.html?f='+ip, 250, 320);
	}

	function openView(t,f,mtype) {
		if(mtype=="img"){
			x_open_full(t, "./page/image.html?name="+encodeURI("/files/"+f));
		}else if(mtype=="dir"){
			x_open_full(t, "./file-lists?path="+encodeURI(f));
		}else{
			//x_open_full(t, f)
			window.open("files/"+f);
		}
	}

	function downLoadOP(f) {
		//window.open("files/"+f);
	}

	function deleteFile(filepath) {
		layer.confirm('确认要删除这个文件吗<br>'+filepath+'', {
			btn : [ '确定', '取消' ]//按钮
		}, function(index) {
			if(index>0){
				httpGet("/api/delete?f=/files"+filepath, function (result) {
					messageOk("删除成功");
					syncSend("reload");
					window.location.reload();
				});
			}
		});
	}



	//下载文件
	downloadFile = function (sUrl) {
		//iOS devices do not support downloading. We have to inform user about this.
		if (/(iP)/g.test(navigator.userAgent)) {
			alert('Your device does not support files downloading. Please try again in desktop browser.');
			return false;
		}

		//If in Chrome or Safari - download via virtual link click
		if (downloadFile.isChrome || downloadFile.isSafari) {
			//Creating new link node.
			var link = document.createElement('a');
			link.href = sUrl;

			if (link.download !== undefined) {
				//Set HTML5 download attribute. This will prevent file from opening if supported.
				var fileName = sUrl.substring(sUrl.lastIndexOf('/') + 1, sUrl.length);
				link.download = fileName;
			}

			//Dispatching click event.
			if (document.createEvent) {
				var e = document.createEvent('MouseEvents');
				e.initEvent('click', true, true);
				link.dispatchEvent(e);
				return true;
			}
		}

		// Force file download (whether supported by server).
		if (sUrl.indexOf('?') === -1) {
			sUrl += '?download';
		}

		window.open(sUrl, '_self');
		return true;
	}

	downloadFile.isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
	downloadFile.isSafari = navigator.userAgent.toLowerCase().indexOf('safari') > -1;

</script>
</body>

</html>